package com.project.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("test")
public class TestController {

    @RequestMapping("speak")
    public String speak(HttpServletRequest request){
        //在request中，绑定共享数据，作用域在一次请求/响应范围之内
        request.setAttribute("name","tom");
        return "redirect:https://www.baidu.com";//以请求转发方式转到指定资源
    }

    @RequestMapping("index")
    public String index(){
        return "redirect:/getInfo";//以重定向方式转到指定资源
    }
}
